package sg.edu.nus.iss.billing.model.user;

import sg.edu.nus.iss.billing.model.BaseModel;

/**
 * @author Yeo Hee Ling
 *
 */
public class User extends BaseModel{
	private static final long serialVersionUID = 1L;
	private String personName;
	private String userName;
	private String password;
	private SystemRole systemRole;
	private SystemAcctStatus systemAcctStatus;
	
	public enum SystemRole {
		ADMIN, AGENT
	}
	
	public enum SystemAcctStatus {
		Active, Suspended
	}
	
	public User (String personName, String userName, String password, SystemRole systemRole, SystemAcctStatus systemAcctStatus) {
		this.personName = personName;
		this.userName = userName;
		this.password = password;
		this.systemRole = systemRole;
		this.systemAcctStatus = systemAcctStatus;
	}

	public String getUserName() {
		return userName;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getPersonName() {
		return personName;
	}

	public void setPersonName(String personName) {
		this.personName = personName;
	}
	
	public SystemRole getSystemRole() {
		return systemRole;
	}
	
	public void setSystemRole(SystemRole systemRole) {
		this.systemRole = systemRole;
	}
	
	public SystemAcctStatus getSystemAcctStatus() {
		return systemAcctStatus;
	}

	public void setSystemAcctStatus(SystemAcctStatus systemAcctStatus) {
		this.systemAcctStatus = systemAcctStatus;
	}
	
	public boolean matches(Object userObj) {
		if(!(userObj instanceof User))
			return false;
		
		User otherUser = (User)userObj;
		if(!this.personName.equals(otherUser.getPersonName()))
			return false;
		if(!this.userName.equals(otherUser.getUserName()))
			return false;
		if(!this.password.equals(otherUser.getPassword()))
			return false;
		if(this.systemRole != otherUser.getSystemRole())
			return false;
		if(this.systemAcctStatus != otherUser.getSystemAcctStatus())
			return false;
		
		return true;
	}
}